package com.zjw.study.basics.java.classinstantiation;

/**
 * 类的实例化过程
 *
 * @author zhangjiwei
 * @version V 1.0
 * @project com.zjw.study.basics.java.classinstantiation
 * @date 2020/6/4 16:00
 */
public class InstantiationProcess extends InstantiationAbstractProcess {

    private String str = "default";

    private static String strStaticBeforeMethod = initStaticBeforeStr();

    private String strMethod = initStr();

    public static String strStaticMethod = initStaticStr();

    {
        System.out.println("代码块");
    }

    static {
        System.out.println("静态代码块");
    }

    public InstantiationProcess() {
        System.out.println("无参构造");
    }

    public InstantiationProcess(String arg) {
        System.out.printf("有参构造 %s\r\n", arg);
    }

    private String initStr() {
        System.out.println("initStr()");
        return "initStr";
    }

    private static String initStaticStr() {
        System.out.println("initStaticStr()");
        return "initStaticStr";
    }

    private static String initStaticBeforeStr() {
        System.out.println("initStaticBeforeStr()");
        return "initStaticBeforeStr";
    }

    public void exec() {
        System.out.println("对象执行啦。。。");
    }

    public void printStr() {
        System.out.println("--------------------");
        System.out.println("str=" + str);
        System.out.println("strStaticBeforeMethod=" + strStaticBeforeMethod);
        System.out.println("strMethod=" + strMethod);
        System.out.println("strStaticMethod=" + strStaticMethod);
    }

    public static void staticPrint() {
        System.out.println("staticPrint()");
    }

}
